package com.reference.reference2.soft;

import java.util.concurrent.TimeUnit;

public class Test {
	
	/**软引用：当内存即将溢出时，会尝试GC soft类型的reference
	 * @param args
	 */
	public static void main(String[] args) {
		SoftLRUCache<Integer, Reference> cache = new SoftLRUCache<>(1000, key -> new Reference());
		for(int i=0; i<Integer.MAX_VALUE; i++){
			cache.get(i);
			try {
				TimeUnit.SECONDS.sleep(1);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
